'use strict';

// const Controller = require('egg').Controller;

const Controller = require('./base');

class SignController extends Controller {

  // 界面列表
  async users() {
    const ctx = this.ctx;
    ctx.set('Content-Type', 'application/json');
    const list = await ctx.service.user.signList(ctx.query);
    this.success(list);
  }

  // 创建界面
  async sign() {
    const ctx = this.ctx;
    var post = ctx.request.body;
    ctx.set('Content-Type', 'application/json');
    if (!post.name || !post.bless || !post.num) {
      this.ctx.throw(500, '参数错误');
    }
    // 如果给了ID，就是更新，没有则添加
    if (!post.id) {
      const sign = await ctx.service.user.sign(post);
      this.success(sign);
    }
  }


}

module.exports = SignController;
